import { http } from '~/server';
import type { PlayList, Subcount, DetailPlayList } from '~/types/songs';
import type { UserProfile } from '~/types/user';

/**
 * 获取用户信息，歌单，收藏，mv,dj数量
 * @returns
 */
export async function getUserSubcount(): Promise<Subcount> {
  return await http.get<Subcount>('/user/subcount');
}

/**
 * 获取用户的个人信息
 * @returns
 */
export async function getUseraccount(): Promise<UserProfile> {
  const res = await http.get<{ code: number; profile: UserProfile }>('/user/account', {
    timestamp: new Date().getTime()
  });
  return res.profile;
}

/**
 * 获取用户的列表
 * @param uid 用户id
 * @returns PlayList
 */
export async function getUserPlaylist(
  uid: string
): Promise<{ code: number; playlist: PlayList[] }> {
  return await http.get<{ code: number; playlist: PlayList[] }>('/user/playlist', {
    uid
  });
}

/**
 * 获取歌单详情
 * @param id 歌单的id
 * @returns
 */
export async function getMusicListsDetail(id: number): Promise<DetailPlayList> {
  return await http.get<DetailPlayList>('/playlist/detail', {
    id
  });
}

/* 获取歌单所有歌曲 */
// export async function getAllMusicLists(id: number, len: number) {
//   return await http.get<{
//       code: number, songs: any[]
//   }>(`/playlist/track/all?id=${id}&limit=${len}&offset=0`)
// }
